package com.theima.socket.socketdemo4;

import java.io.IOException;
import java.net.*;

/**
 * @program: Myset
 * @description:组播的接受端是一组计算机。
 * @author: xuejingjing
 * @create: 2021-06-25 00:47
 **/
public class ClinetDemo {
    public static void main(String[] args) throws IOException {

        DatagramSocket datagramSocket = new DatagramSocket();

        //4个参数，地址，端口号
        String s ="hello 组播";
        byte[] bytes = s.getBytes();
        //你要发送的电脑，组播地址
        InetAddress address = InetAddress.getByName("224.0.1.0");
        int port = 10000;

        DatagramPacket dp = new DatagramPacket(bytes, bytes.length,address,port);
        datagramSocket.send(dp);

        datagramSocket.close();

    }
}
